package com.css.fxfzypg.modules.rating.thread;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 业务线程池统一管理
 * author：胡图图
 */
public class BizThreadPoolManage {
    public static int queueSize = Runtime.getRuntime().availableProcessors();
    public static ThreadPoolExecutor exeBizThreadPoolExecutor = // 业务调度线程 线程数：cpu核数 * 2 + 3
            new ThreadPoolExecutor(queueSize * 2 + 3, queueSize * 2 + 3, 0L, TimeUnit.MILLISECONDS,
                    new LinkedBlockingQueue<Runnable>());

    /**
     * 使用案例
     *
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            BizThreadPoolManage.exeBizThreadPoolExecutor.execute(() -> {
                System.out.println(1);
            });
        }
    }
}
